package com.gitee.feizns.quickstart.jackson.filter;

import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.PropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;

/**
 * 忽略基础类型的过滤器
 * @author feizns
 * @since 2023/4/6
 */
public class IgnorePrimitiveSimpleBeanPropertyFilter extends SimpleBeanPropertyFilter {

    @Override
    protected boolean includeElement(Object elementValue) {
        return elementValue != null && !elementValue.getClass().isPrimitive();
    }

    @Override
    protected boolean include(PropertyWriter writer) {
        return !writer.getType().isPrimitive();
    }

    @Override
    protected boolean include(BeanPropertyWriter writer) {
        return !writer.getType().isPrimitive();
    }

}
